import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { OperateLogPageVO, OperateLogQuery } from "./types";

/**
 * 获取操作日志。
 *
 * @param queryParams 查询参数
 */
export function getOperateLogPage(
  queryParams: OperateLogQuery
): AxiosPromise<PageResult<OperateLogPageVO[]>> {
  return request({
    url: "/api/v1/system/operateLog/operate",
    method: "get",
    params: queryParams,
  });
}

/**
 * 移除指定唯一性 ID 的操作日志。
 *
 * @param id 唯一性 ID
 */
export function removeOperateLogs(ids: string) {
  return request({
    url: `/api/v1/system/operateLog/delete/${ids}`,
    method: "delete",
  });
}

/**
 * 移除全部操作日志。
 */
export function removeAllOperateLogs() {
  return request({
    url: `/api/v1/system/operateLog/deleteAll`,
    method: "delete",
  });
}

/**
 * 导出操作日志。
 */
export function exportOperateLog() {
  return request({
    url: `/api/v1/system/operateLog/export`,
    method: "get",
    responseType: "arraybuffer",
  });
}
